const app = getApp();

function inArray(arr, key, val) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i][key] === val) {
      return i;
    }
  }
  return -1;
}

//字符串转buffer 十六进制
function stringToHexBuffer(data) {
  var typedArray = new Uint8Array(data.match(/[\da-f]{2}/gi).map(function (h) {
    return parseInt(h, 16)
  }))

  return typedArray.buffer
}

// 字符串转byte
function stringToBytes(str) {
  var array = new Uint8Array(str.length);
  for (var i = 0, l = str.length; i < l; i++) {
    array[i] = str.charCodeAt(i);
  }
  console.log(array);
  return array.buffer;
}

// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
  var hexArr = Array.prototype.map.call(
    new Uint8Array(buffer),
    function (bit) {
      return ('00' + bit.toString(16)).slice(-2)
    }
  )
  return hexArr.join('');
}
// import bluetoothUtil from '../../utils/bluetooth-util'
// home/BleHome.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    IsConnect: false,
    showConnect: false,
    showStartBtn: false
  
  },

  userInfo:function(){
    wx.navigateTo({
      url: '../useAdmin/useAdmin' 
    })
  },
  realTimeData:function(){
    wx.navigateTo({
      url: '../realTimeData/realTimeData' 
    })
  },
  showData:function(){
    wx.navigateTo({
      url: '../showData/showData' 
    })
  },
  physicalData:function(){
    wx.navigateTo({
      url: '../physicalData/physicalData' 
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    this.setData({
      IsConnect:wx.getStorageSync('IsConnect')
    });
  },

  // 同步数据
  upload:function(){
    // bluetoothUtil.writeBLECharacteristicValue("REQDATA");
  },

 
})